package pl.edu.amu.wmi.kino.visualjavafx.model.animation.interpolators;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;




/**
 *  <p style="margin-top: 0">
 *    This interpolation returns the end value regardles of &quot;howMuch&quot;
 *      </p>
 */
// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.A2CBA06E-C0C3-7B08-E523-8219240186BC]
// </editor-fold> 
public class DiscreteInterpolator implements Interpolation ,java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport= new PropertyChangeSupport(this);
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.27C66B2C-F8E9-2617-E6C7-C71695180E1C]
    // </editor-fold> 
    public DiscreteInterpolator () {
    }

    /**
     *  <html>
     *    <head>
     *  
     *    </head>
     *    <body>
     *      <p style="margin-top: 0">
     *    returns value between startVal and endVal after completing howMuch of it 
     *    - if howMuch is greater than 1 - it treats it as if it would be 1.
     *      </p>
     *    </body>
     *  </html>
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.C878E9D1-8977-CD98-A7BA-8225206B5721]
    // </editor-fold> 
    @Override
    public double getValue (double howMuch, double startVal, double endVal) {
        if(howMuch==0)
            return startVal;
        else if(howMuch>0)
            return endVal;
        else throw new ArithmeticException();
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.B5A2E3E3-723A-D559-D817-A479A5336CE9]
    // </editor-fold> 
    @Override
    public double getValueAtTime (double howMuch, double Time, double startVal, double endVal) {
        return this.getValue(howMuch, startVal, endVal);
    }

    @Override
    public String getName() {
        return this.name;
    }
    private String name="DISCRETE";
}

